/**
 * Created by yuweimei on 2018/1/17.
 */
window.onload=function(){
    var loginbtn=document.getElementById("login");
    loginbtn.onclick=function(){
        Toast('登录成功！',2000);
    }

    //自定义弹框
    function Toast(msg,duration)
    {
        duration=isNaN(duration)?3000:duration;
        var m = document.createElement('div');
        m.innerHTML = msg;
        m.style.cssText="width:50%; min-width:10rem; background:#000; opacity:0.6; height:3rem;"+
            "color:#fff; line-height:3rem; text-align:center; border-radius:3rem; position:fixed; "+
            "top:50%; left:25%; z-index:999999;";
        document.body.appendChild(m);
        setTimeout(function() {
            var d = 0.5;
            m.style.webkitTransition = '-webkit-transform ' + d + 's ease-in, opacity ' + d + 's ease-in';
            m.style.opacity = '0';
            setTimeout(function() { document.body.removeChild(m) }, d * 1000);
        }, duration);
    }

}
